import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  isPractice: false, // 练习模式标志
  flag: false, // 菜单栏左右滑动标志
  userInfo: null,
  menu: [
    {
      index: '1',
      title: '考试管理',
      icon: 'el-icon-a-061',
      content: [
        { item2: '考试查询', path: '/selectExam', icon: 'el-icon-a-042' },
        { item3: '添加考试', path: '/addExam', icon: 'el-icon-a-07' },
      ],
    },
    {
      index: '2',
      title: '题库管理',
      icon: 'el-icon-a-011',
      content: [
        { item2: '题目列表', path: '/selectAnswer', icon: 'el-icon-a-041' },
        { item3: '新增题目', path: '/addAnswer', icon: 'el-icon-a-07' },
        { item4: '题库列表', path: '/question-bank', icon: 'el-icon-s-order' },
        { path: '/addAnswerChildren' },
      ],
    },
    {
      index: '3',
      title: '成绩查询',
      icon: 'el-icon-a-021',
      content: [
        { item1: '学生成绩查询', path: '/allStudentsGrade', icon: 'el-icon-a-042' },
        { path: '/grade' },
        { item2: '成绩分段查询', path: '/selectExamToPart', icon: 'el-icon-a-042' },
        { path: '/scorePart' },
      ],
    },
    {
      index: '4',
      title: '学生管理',
      icon: 'el-icon-a-01',
      content: [
        { item1: '学生管理', path: '/studentManage', icon: 'el-icon-a-041' },
        { item2: '添加学生', path: '/addStudent', icon: 'el-icon-a-07' },
        { item3: '批量添加学生', path: '/addStudents', icon: 'el-icon-a-07' },
      ],
    }
  ],
}

const mutations = {
  practice(state, status) {
    state.isPractice = status
  },
  toggle(state) {
    state.flag = !state.flag
  },
  changeUserInfo(state, info) {
    state.userInfo = info
  }
}

const getters = {}

const actions = {
  getUserInfo(context, info) {
    context.commit('changeUserInfo', info)
  },
  getPractice(context, status) {
    context.commit('practice', status)
  }
}

export default new Vuex.Store({
  state,
  mutations,
  getters,
  actions,
})